1400A - String Similarity - CodeForces Solution


constructive algorithms strings *800

Please click on ads to support us..

Python Code:

n = int(input())
for i in range(n):
    x = int(input())
    s = input()
    k =""
    for j in range(0,x):
        k = k+s[x-1]
    print(k)

C++ Code:

//Idk how it works but it works
//¯\_(ツ)_/¯

#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

#define int long long
#define ll long long
#define cy cout << "YES"
#define cn cout << "NO"
#define eb emplace_back
#define itn int
#define fro for
#define cotu cout

void output( bool fl ) {
    if( fl ) cy;
    else cn;
    cout << endl;
}

int solve ( ) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    for( int i = 0; i < n; i++ ) {
        cout << s[n - 1];
    }
    cout << endl;
}

main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin.exceptions(ios::badbit | ios::failbit);
    setlocale( LC_ALL, "Ukr" );

    int t = 1;
    cin >> t;
    while( t-- ) {
        solve();
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

514B - Han Solo and Lazer Gun
898B - Proper Nutrition
9C - Hexadecimal's Numbers
1265B - Beautiful Numbers
745A - Hongcow Learns the Cyclic Shift
873A - Chores
1754B - Kevin and Permutation
1547D - Co-growing Sequence
1754D - Factorial Divisibility
1117B - Emotes
412B - Network Configuration
845B - Luba And The Ticket
1732A - Bestie
389A - Fox and Number Game
1732B - Ugu
1100B - Build a Contest
1181B - Split a Number
1313B - Different Rules
1736D - Equal Binary Subsequences
1754A - Technical Support
26B - Regular Bracket Sequence
699A - Launch of Collider
474D - Flowers
1016A - Death Note
1335C - Two Teams Composing
1167C - News Distribution
813C - The Tag Game
1130C - Connect
1236B - Alice and the List of Presents
845C - Two TVs